<template>
  <div class='constent'>
    <el-dialog title="提示" :visible="dialogVisibleAudit" width="400px" :before-close="handleClose">
      <el-radio-group v-model="data.chkState" @change="noChange" style="margin-bottom: 18px;">
        <el-radio :label="1">通过</el-radio>
        <el-radio :label="2">拒绝</el-radio>
      </el-radio-group>
        <el-input type="textarea" placeholder="请输入审核意见" v-model="data.chkRemarks" show-word-limit style="margin-bottom: 18px;" />
        <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" @click="isOk">确 定</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  props: {
    dialogVisibleAudit: {
      type: Boolean,
      default: false
    },
    auditDataId: {
      type: Number
    }
  },
  data () {
    return {
      data: {
        // 单选框
        chkState: 1,
        // 文本域
        chkRemarks: '',
        id: ''
      }
    }
  },
  methods: {
    handleClose () {
      this.$emit('update:dialogVisibleAudit', false)
      this.data = {
        chkRemarks: '',
        chkState: 1,
        id: ''
      }
    },
    noChange (value) {
      this.data.chkState = value
    },
    isOk () {
      if (this.data.chkRemarks === '') {
        this.$message.warning('请输入审核意见')
      } else {
        this.data.id = this.auditDataId
        choiceCheck(this.data).then(() => {
          this.$message.success('操作成功')
          this.handleClose()
          this.$emit('on')
        }).catch(err => {
          console.log(err)
        })
      }
    }
  }
}
</script>

<style scoped lang='scss'>
.dialog-footer {
  position: relative;
  left: 102px;
}
</style>
